package com.edu.method;

import java.util.Scanner;

public class MethodPractice06 {
    public static void main(String[] args) {
        //数字加密：首先输入一串数字，将每位进行加五，再对10取余，然后再进行反转成一串新数字
        System.out.println("请输入你选择加密的数字个数：");
        Scanner s = new Scanner(System.in);
        int num=s.nextInt();
        int[] a=new int[num];
        for (int i = 0; i < a.length; i++) {
            a[i]=s.nextInt();
        }
        printArray(a);//打印一遍原始数组
        newArray(a);//数组加密
        printArray(a);//再打印一边加密后的数组

    }
    //将数组打印一遍
    public static void printArray(int[] a){
        System.out.print("a=[");
        for (int i = 0; i < a.length; i++) {
            System.out.print(i==a.length-1?a[i]:(a[i]+","));
        }
        System.out.println("]");
    }
    //将数组进行加密，形成一个新数组
    public static int[] newArray(int[] a){
        for (int i = 0; i < a.length; i++) {
            a[i]=(a[i]+5)%10;
        }
        for (int i = 0,j=a.length-1; i < j; i++,j--) {
            int temp=a[i];
            a[i]=a[j];
            a[j]=temp;
        }
        return a;
    }
}
